package com.geostar.constructionland.common.entity.response;


import java.io.Serializable;

/**
 * Extjs Ajax 返回数据
 */
public class ExtJsAjaxResponse<T> implements Serializable {
    private String success;
    private String message;
    private T data;
    public ExtJsAjaxResponse(){}
    private ExtJsAjaxResponse(String success) {
        this.success = success;
    }

    public ExtJsAjaxResponse(String success, String message) {
        this.success = success;
        this.message = message;
    }

    public ExtJsAjaxResponse(String success, T data) {
        this.success = success;
        this.data = data;
    }

    private ExtJsAjaxResponse(String success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;

    }

    public String getsuccess() {
        return success;
    }

    public T getData() {
        return data;
    }

    public String getMessage() {
        return message;
    }

    public static <T> ExtJsAjaxResponse<T> createBySuccess() {
        return new ExtJsAjaxResponse<T>(ExtJsAjaxCode.SUCCESS.getSuccess(), ExtJsAjaxCode.SUCCESS.getDesc());
    }

    public static <T> ExtJsAjaxResponse<T> createBySuccessMessage(String message) {
        return new ExtJsAjaxResponse<T>(ExtJsAjaxCode.SUCCESS.getSuccess(), message);
    }

    public static <T> ExtJsAjaxResponse<T> createBySuccess(T data) {
        return new ExtJsAjaxResponse<T>(ExtJsAjaxCode.SUCCESS.getSuccess(), ExtJsAjaxCode.SUCCESS.getDesc(), data);
    }

    public static <T> ExtJsAjaxResponse<T> createBySuccess(String message, T data) {
        return new ExtJsAjaxResponse<T>(ExtJsAjaxCode.SUCCESS.getSuccess(), message, data);
    }

    public static <T> ExtJsAjaxResponse<T> createByError() {
        return new ExtJsAjaxResponse<T>(ExtJsAjaxCode.ERROR.getSuccess(), ExtJsAjaxCode.ERROR.getDesc());
    }

    public static <T> ExtJsAjaxResponse<T> createByErrorMessage(String errorMessage) {
        return new ExtJsAjaxResponse<T>(ExtJsAjaxCode.ERROR.getSuccess(), errorMessage);
    }

    public static <T> ExtJsAjaxResponse<T> createByErrorCodeMessage(String errorCode, String errorMessage) {
        return new ExtJsAjaxResponse<T>(errorCode, errorMessage);
    }
}
